﻿<%@ Page Title="Quản lý thương hiệu xe" MasterPageFile="~/Admin/Site.Master" Language="C#" AutoEventWireup="true" CodeBehind="QLThuongHieuXe.aspx.cs" Inherits="Transport.Admin.QLThuongHieuXe" %>
<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<% 
    if (Session["loainguoidung"] == null)
    {
        Response.Redirect("../Default.aspx");
    }
    else
    {
        if (Session["loainguoidung"].ToString() != "ADMIN")
            Response.Redirect("Default.aspx");
    }  
    %>
<p>
    <b>Mã thương hiệu:</b>
    <asp:TextBox ID="txt_ID" runat="server"></asp:TextBox>
    <b>Tên thương hiệu:</b>
    <asp:TextBox ID="txt_Name" runat="server"></asp:TextBox>
    <asp:Button ID="btn_Search" runat="server" Text="Tìm" />
</p>
<p>
    <b>Hãng xe:</b>
    <asp:DropDownList ID="ddl_Hang" runat="server" AutoPostBack="True" 
        DataSourceID="EntityDataSource_Hang" DataTextField="ten_hang_xe" 
        DataValueField="ma_hang_xe" AppendDataBoundItems="true">
        <asp:ListItem text="Select All" value="-1" />
    </asp:DropDownList>
    <asp:EntityDataSource ID="EntityDataSource_Hang" runat="server" 
        ConnectionString="name=transportEntities" 
        DefaultContainerName="transportEntities" EnableFlattening="False" 
        EntitySetName="hang_xe">
    </asp:EntityDataSource>
</p>
<p>
    <asp:GridView ID="GridView_Brand" runat="server" AllowPaging="True" 
        AutoGenerateColumns="False" CellPadding="4" DataKeyNames="ma_thuong_hieu" CellSpacing="4"
        DataSourceID="EntityDataSource_Brand" ForeColor="#333333" GridLines="None">
        <AlternatingRowStyle BackColor="White" />
        <Columns>
            <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
            <asp:BoundField DataField="ma_thuong_hieu" HeaderText="Mã thương hiệu" 
                ReadOnly="True" SortExpression="ma_thuong_hieu" />
            <asp:BoundField DataField="ten_thuong_hieu" HeaderText="Tên thương hiệu" 
                SortExpression="ten_thuong_hieu" />
            <asp:TemplateField HeaderText="Hãng xe">
                <ItemTemplate>
                     <asp:DropDownList ID="ddl_uHang" runat="server"
                        DataSourceID="EntityDataSource_Hang" DataTextField="ten_hang_xe" 
                        DataValueField="ma_hang_xe" SelectedValue='<%# Bind("ma_hang_xe") %>'>
                     </asp:DropDownList>
                </ItemTemplate>
                <EditItemTemplate>
                    <asp:DropDownList ID="ddl_uHang1" runat="server"
                        DataSourceID="EntityDataSource_Hang" DataTextField="ten_hang_xe" 
                        DataValueField="ma_hang_xe" SelectedValue='<%# Bind("ma_hang_xe") %>'>
                    </asp:DropDownList>
                </EditItemTemplate>
            </asp:TemplateField>
            <asp:BoundField DataField="so_cho" HeaderText="Số chỗ" 
                SortExpression="so_cho" />
            <asp:BoundField DataField="hinh_anh" HeaderText="Hình ảnh" 
                SortExpression="hinh_anh" />
        </Columns>
        <FooterStyle BackColor="#7FB308" Font-Bold="True" ForeColor="White" />
        <HeaderStyle BackColor="#7FB308" Font-Bold="True" ForeColor="White" />
        <PagerStyle BackColor="#FFCC66" ForeColor="#333333" HorizontalAlign="Center" />
        <RowStyle BackColor="#FFFBD6" ForeColor="#333333" />
        <SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="Navy" />
        <SortedAscendingCellStyle BackColor="#FDF5AC" />
        <SortedAscendingHeaderStyle BackColor="#4D0000" />
        <SortedDescendingCellStyle BackColor="#FCF6C0" />
        <SortedDescendingHeaderStyle BackColor="#820000" />
    </asp:GridView>
    <asp:EntityDataSource ID="EntityDataSource_Brand" runat="server" 
        ConnectionString="name=transportEntities" 
        DefaultContainerName="transportEntities" EnableDelete="True" 
        EnableFlattening="False" EnableInsert="True" EnableUpdate="True" 
        EntitySetName="thuong_hieu" EntityTypeFilter="thuong_hieu"
        Where="it.ma_hang_xe = CASE WHEN @Hang = '-1' THEN  it.ma_hang_xe ELSE @Hang END" >
        <WhereParameters>
            <asp:ControlParameter ControlID="ddl_Hang" Type="String"
                Name="Hang" PropertyName="SelectedValue" />
        </WhereParameters>
    </asp:EntityDataSource>
    <asp:QueryExtender ID="qeSearch" runat="server" TargetControlID="EntityDataSource_Brand">
        <asp:SearchExpression DataFields="ma_thuong_hieu" SearchType="Contains">
            <asp:ControlParameter ControlID="txt_ID" />
        </asp:SearchExpression>
        <asp:SearchExpression DataFields="ten_thuong_hieu" SearchType="Contains">
            <asp:ControlParameter ControlID="txt_Name" />
        </asp:SearchExpression>
        <asp:OrderByExpression DataField="ma_thuong_hieu" Direction="Ascending" />
    </asp:QueryExtender>
</p>
<p>
    <asp:DetailsView ID="DetailsView_Brand" runat="server" Height="50px" 
        Width="125px" AutoGenerateRows="False" BackColor="White" BorderColor="#CCCCCC" 
        BorderStyle="None" BorderWidth="1px" CellPadding="4" 
        DataKeyNames="ma_thuong_hieu" DataSourceID="EntityDataSource_Brand" FieldHeaderStyle-Wrap="false"
        DefaultMode="Insert" ForeColor="Black" GridLines="Horizontal" 
        oniteminserted="DetailsView_Brand_ItemInserted">
        <EditRowStyle BackColor="#7FB308" Font-Bold="True" ForeColor="White" />
        <Fields>
            <asp:BoundField DataField="ma_thuong_hieu" HeaderText="Mã thương hiệu" 
                ReadOnly="True" SortExpression="ma_thuong_hieu" />
            <asp:BoundField DataField="ten_thuong_hieu" HeaderText="Tên thương hiệu" 
                SortExpression="ten_thuong_hieu" />
                        <asp:TemplateField HeaderText="Hãng xe">
                <InsertItemTemplate>
                     <asp:DropDownList ID="ddl_iHang" runat="server"
                        DataSourceID="EntityDataSource_Hang" DataTextField="ten_hang_xe" 
                        DataValueField="ma_hang_xe" SelectedValue='<%# Bind("ma_hang_xe") %>'>
                     </asp:DropDownList>
                </InsertItemTemplate>
            </asp:TemplateField>
            <asp:BoundField DataField="so_cho" HeaderText="Số chỗ" 
                SortExpression="so_cho" />
            <asp:BoundField DataField="hinh_anh" HeaderText="Hình ảnh" 
                SortExpression="hinh_anh" />
            <asp:CommandField ShowInsertButton="True" />
        </Fields>
        <FooterStyle BackColor="#CCCC99" ForeColor="Black" />
        <HeaderStyle BackColor="#333333" Font-Bold="True" ForeColor="White" />
        <PagerStyle BackColor="White" ForeColor="Black" HorizontalAlign="Right" />
    </asp:DetailsView>
</p>
</asp:Content>
